package com.woniuxy.common.mapper;

import com.woniuxy.common.entity.ForumAdminApply;
import com.woniuxy.common.entity.ForumAdminApplyExample;
import com.woniuxy.common.entity.ForumForum;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.*;

public interface ForumAdminApplyMapper {
    long countByExample(ForumAdminApplyExample example);

    int deleteByExample(ForumAdminApplyExample example);

    int deleteByPrimaryKey(String id);

    int insert(ForumAdminApply record);

    int insertSelective(ForumAdminApply record);

    List<ForumAdminApply> selectByExampleWithBLOBs(ForumAdminApplyExample example);

    List<ForumAdminApply> selectByExample(ForumAdminApplyExample example);

    ForumAdminApply selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") ForumAdminApply record, @Param("example") ForumAdminApplyExample example);

    int updateByExampleWithBLOBs(@Param("record") ForumAdminApply record, @Param("example") ForumAdminApplyExample example);

    int updateByExample(@Param("record") ForumAdminApply record, @Param("example") ForumAdminApplyExample example);

    int updateByPrimaryKeySelective(ForumAdminApply record);

    int updateByPrimaryKeyWithBLOBs(ForumAdminApply record);

    int updateByPrimaryKey(ForumAdminApply record);

    /**
     * @return java.util.Map<java.lang.String, java.lang.Object>
     * @Author ArmWatt
     * @Date 2020/5/13
     * @Param []
     * @Description 查询待审核社区吧主申请记录
     **/
    @Select("select fa.id AS id , fa.user_id AS userid,fa.forum_id AS forumid, cu.name AS username, ff.name AS forumname, fa.status, fa.content from forum_admin_apply AS fa ,center_user AS cu ,forum_forum AS ff where fa.user_id=cu.id and fa.forum_id=ff.id AND fa.status='1' AND cu.center_accountstatus ='1'")
    List<Map<String, Object>>queryAllWaitApply();

    /**
     * @return int
     * @Author ArmWatt
     * @Date 2020/5/13
     * @Param [id]
     * @Description 审核通过
     **/
    @Update("update forum_admin_apply set status='2' where id=#{id}")
    int passApply(String id);

    /**
     * @return int
     * @Author ArmWatt
     * @Date 2020/5/13
     * @Param [id]
     * @Description 审核拒绝
     **/
    @Update("update forum_admin_apply set status='3' where id=#{id}")
    int rejectApply(String id);
}